<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// +----------------------------------------------------------------------+
// | Authors	: Tung, Nguyen Dam                                        |
// | Email		: mask_final@yahoo.com									  | 								
// | Mobile		: (+84) 936 885 466                                       |
// | Date		: 06/2011												  |							
// +----------------------------------------------------------------------+
// | Copyrights (C) 2011                                                  |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+

class Block{
	public $name;
	public $view;
	public $db;
	public $variable;
	
	public function __construct(){
		$this->view = new View();		
	}
}

class View{
	public $variable = array();
	public $data;
	
	public function assign($key, $val){
		$this->variable[$key] = $val;
	}
	
	public function load($view, $return = true){
		$ci =& get_instance();
		
		$path = 'blocks/block_' . $ci->block->name. '/tpl/' . $view . ".php";
		ob_start();			
			extract($this->variable);
			require_once($path);
			$this->data = ob_get_contents();		
		ob_end_clean();
		
		if($return == true){
			echo $this->data;
		}else{
			return $this->data;
		}	
	}
}
